package com.android.jianboshi.ui.activity;

import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.android.baselibrary.view.Comm_HeadView;
import com.android.jianboshi.R;
import com.android.jianboshi.adapter.HitsListAdapter;
import com.android.jianboshi.event.Event_Notification;
import com.android.jianboshi.manager.BluetoothHelper;
import com.android.jianboshi.manager.BoxingManager;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;

public class TestActivity extends BaseActivity {

    @BindView(R.id.comm_title)
    Comm_HeadView comm_title;
    //    @BindView(R.id.tv_air)
//    TextView tv_air;
//    @BindView(R.id.tv_air1)
//    TextView tv_air1;
    @BindView(R.id.tv_times)
    TextView tv_times;
    @BindView(R.id.recyclerview)
    RecyclerView recyclerview;

    BluetoothHelper bluetoothHelper;
    BoxingManager boxingManager = new BoxingManager();
    HitsListAdapter adapter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_test;
    }

    @Override
    protected void initView() {
        comm_title.setTitle("测试1");
        recyclerview.setLayoutManager(new LinearLayoutManager(mContext));
        adapter = new HitsListAdapter(mContext, null);
        recyclerview.setAdapter(adapter);
        adapter.setData(boxingManager.airPressureList);
    }

    @Override
    protected boolean isRegistEventbus() {
        return true;
    }

    @Override
    protected void initData() {
        getData();
    }

    private void getData() {

    }

    public void showResult() {
        adapter.notifyDataSetChanged();
        tv_times.setText(boxingManager.airPressureList.size() + "");
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(Event_Notification event) {
        boxingManager.parseScanResult(event.data);
        showResult();
    }
}
